/*
 * Automata.h
 * Behavioral Attributed Automaton
 * @author Gregoire JACOB (gregoire.jacob@orange-ftgroup.com)
 * @date 01/12/2008
 * @version 2.2
 * Automaton structures
 */


//Object types
#define TYPE_VAR	1
#define TYPE_PERM	2
#define TYPE_TEMP	3
#define TYPE_COM	4
#define TYPE_BOOT	5
#define TYPE_THIS	6

//Node structure
struct NODE{
	char	node;
	long	objids[3];
	int		objtypes[3];
};

struct PARSED_AUTOMATON{
	int		nbnode;
	int		nbmaxnode;
	struct NODE * progression;
};

struct PARALLEL_AUTOMATA{
	int		nbnautomata;
	int		nbmaxautomata;
	struct PARSED_AUTOMATON * automata;
};

#define AUT_CLUSTER_SIZE 25
#define NOD_CLUSTER_SIZE 5

//Update and Access methods (current is the last node)
void setCurrentState(char s, struct PARSED_AUTOMATON * parautomaton);
char getCurrentState(struct PARSED_AUTOMATON * parautomaton);
void getCurrentAttributes(struct PARSED_AUTOMATON * parautomaton,
						  long ids[3], int types[3]);

//Printing methods
void printNode(struct NODE * nod);
void printAutomaton(struct PARSED_AUTOMATON * automat);

/**
 * addNodes()
 * @param the automaton whose progression is updated
 * @param the name of the added node
 * @param the new identifier attibutes
 * @param the new types attributes
 * Update the progression of an automaton adding the next node
 */
void addNode(struct PARSED_AUTOMATON * parautomaton, 
			 char node, long ids[3], int types[3]);

/**
 * startAutomaton()
 * @param the pool of parallel automata
 * @param the name of the starting node
 * @param the new identifier attibutes
 * @param the new types attributes
 * Create a new automaton in parallel of the others with the
 * given start symbol
 */
void startAutomaton(struct PARALLEL_AUTOMATA * parautomata, 
				    char node, long ids[3], int types[3]);

/**
 * deleteAutomaton()
 * @param the pool of parallel automata
 * @param the index of the automaton to delete
 * Delete the automaton at the given index
 */
void deleteAutomaton(struct PARALLEL_AUTOMATA * parautomata, int index);